const { Sequelize } = require('sequelize');
const dbConfig = require('../config/db.config');
const { DataTypes } = require('sequelize');
const LogWrite = require('../../utils/logger')

const sequelize = new Sequelize(
    dbConfig.mysql.database,
    dbConfig.mysql.user,
    dbConfig.mysql.password,
    {
        host: dbConfig.mysql.host,
        dialect: 'mysql',
        timezone:'+08:00',
        pool: {
            max: 10,
            min: 1,
            idle: 100000
        }
    });

// User
const User = sequelize.define('user_info', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    username: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true
    },
    password: {
        type: DataTypes.STRING,
        allowNull: false
    },
    salt: {
        type: DataTypes.STRING,
        allowNull: false
    },
    register_time: {
        type: DataTypes.STRING,
        allowNull: false
    }
}, {
    freezeTableName: true,
    timestamps: false
})

module.exports = User